#
# Copyright (C) 2017 Jianhui Zhao <zhaojh329@gmail.com>
#
# This is free software, licensed under the MIT.
#

include $(TOPDIR)/rules.mk
include ../oui.mk

PKG_NAME:=oui-ui-core
PKG_VERSION:=$(strip $(call findrev))
PKG_RELEASE:=1
PKG_MAINTAINER:=Jianhui Zhao <zhaojh329@gmail.com>

PKG_LICENSE:=MIT

include $(INCLUDE_DIR)/package.mk

define Package/oui-ui-core
  SECTION:=oui
  CATEGORY:=Oui
  TITLE:=Oui ui core
  DEPENDS:=+oui-httpd
  URL:=https://github.com/zhaojh329/oui
endef

define Package/oui-httpd/conffiles
endef

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)/
	$(CP) -rf ./ $(PKG_BUILD_DIR)/
	$(RM) -rf $(PKG_BUILD_DIR)/vue/dist
	#npm config set registry https://registry.npmmirror.com
	#nvm use 8
endef


define Build/Compile
	cd $(PKG_BUILD_DIR)/vue && node --version && npm install && npm run build
endef


define Package/oui-ui-core/install
	$(INSTALL_DIR) $(1)/etc/config $(1)/usr/share/oui/menu.d $(1)/www
	$(INSTALL_CONF) ./files/oui.menu $(1)/usr/share/oui/menu.d/oui.json
	#$(INSTALL_CONF) ./files/oui.config $(1)/etc/config/oui-first-login
	$(CP) -rf ./files/i18n $(1)/www
	$(CP) -rf $(PKG_BUILD_DIR)/vue/dist/* $(1)/www
endef

$(eval $(call BuildPackage,oui-ui-core))
